package com.example.adapter;

import java.util.List;

import com.example.entity.Task;


import com.example.happywork.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class TaskAdapter extends ArrayAdapter<Task>{
	
	int resourceId;

	public TaskAdapter(Context context, int resource) {
		super(context, resource);
		resourceId = resource;
	}

	public TaskAdapter(Context context, int resource, List<Task> objects) {
		super(context, resource, objects);
		resourceId = resource;
	}

	public View getView(final int position, View convertView, ViewGroup arg2) {
		Task task = getItem(position);
		View view = LayoutInflater.from(getContext()).inflate(resourceId, null);
		
		TextView taskTitle = (TextView) view.findViewById(R.id.one_task_title);
		TextView taskValue = (TextView) view.findViewById(R.id.one_task_value);
		TextView taskNum = (TextView) view.findViewById(R.id.one_task_num);
		
		taskTitle.setText(task.getTitle());
		taskValue.setText("+" + task.getValue());
		taskNum.setText(task.getFinishedNum() + "/" +task.getNum());
		
		return view;
	}
	
	
	
	
	
	
	
	
}
